1. Field of the Invention
The present invention relates to a data storage apparatus represented by a hard disk drive, and more particularly to optimization of the execution order, write requests (Write Commands) for data to a medium and read requests (Read Commands) for data written to a storage medium.
2. Background Art
A hard disk drive is one of the most popular kinds of computer external storage apparatus. As is well known, on a magnetic disk that is the storage medium of a hard disk drive, tracks that divide the disk surface like annual tree rings are further divided radially into sectors, which are the minimum data recording units. The nearer the periphery of a disk, the higher is the possible linear recording density. With the Zoned Bit Recording method, which is the current mainstream magnetic disk data recording method, all tracks are grouped into a number of zones, and the linear recording density is uniform within each zone. Thus, since the length of a sector is normally 512 bytes, the number of sectors increases the nearer a track is to the periphery of a magnetic disk.
A hard disk drive is provided with a magnetic head for reading data recorded on a magnetic disk or writing data to a magnetic disk. This magnetic head is attached to an actuator mechanism that is made to oscillate by a VCM (Voice Coil Motor). When the magnetic head performs a data read or data write, the magnetic head is moved to and positioned at a prescribed track by driving the actuator mechanism. Movement of the magnetic head to a prescribed position is performed with the help of servo information recorded on the magnetic disk.
One method employed to improve the performance of a data storage apparatus such as a hard disk drive is to use cache memory and to cache write requests from the host system. With this method, when there is a write request from the host system, the host system command is completed by caching data in a cache memory, and subsequently writing the cached write request to the disk when there is no longer a command from the host system.
At this time, a single ring buffer method is generally used for cache memory handling. With the single ring buffer method, write requests from the host system are cached in a cache memory in time series form, and cached write requests are written to the disk starting with the oldest of those cached write requests. When all of the cache memory has been used up, caching continues from the start of the cache memory.
However, when cache memory is used to the end and is filled with data, there is no usable vacant area in the cache memory, and therefore no new caching is possible, as long as the oldest write request has not been written to the disk. That is to say, processing for commands from the host system cannot be completed until the oldest write request in the cache memory is written to the disk and a vacant area is provided in the cache memory.
When a write request is cached in a cache memory that employs a single ring buffer method in this way, if there is a read request from the host system, since processing proceeds in a time series, all cached write requests are first written to the disk, and then the read request is processed.
In order to process this read request more quickly, a method (Read Before Pending Write: RBPW) has been adopted whereby, when there is a read request, the read request is processed before write requests stored in a cache memory.
However, the disk write order of write requests has come to be optimized by using an algorithm such as RPO (Rotational Positioning Optimization) whereby all write requests cached in a cache memory can be written to the disk in the shortest time in units of write requests from the host system. With RPO, when a pending command is executed, the seek time from the start of a seek to the target track on the magnetic disk until that track is reached, and the disk latency until access of the target sector is started after the target track is reached, are predicted. Then, the pending command for which the sum of this seek time and latency is shortest is selected as the next command to be executed.
As a result of optimization of the disk write order by means of RPO, the disk write order for write requests cached in a cache memory ceases to be a time series, and it is even possible that the oldest write request may actually be the last to be written to the disk.
In such a case, even if there is a read request from the host system, since only a single ring buffer method is used, a command from the host system cannot be processed until the oldest write request is written to the disk, and in effect host system commands are kept waiting until all write requests cached in a cache memory have been written to the disk. Consequently, if there is a read request after write requests that use a large amount of a cache memory, it is probable that the host system will have to wait a very long time.